Light-Weight Java Game Library
Introduction
The Lightweight Java Game Library (LWJGL) is an open-source software library that provides bindings to a variety of C libraries for video game developers to Java. It exposes cross-platform libraries commonly used in developing video games and multimedia titles, such as Vulkan, OpenGL, OpenAL and OpenCL.
The primary goal of the project is to provide a way for Java developers to get access to resources that are otherwise unavailable or poorly implemented on the existing Java platform. The main philosophy is to expose underlying technology as a thin wrapper, thus creating an API close to the original.
Setting up LWJGL
Step 1: Install JDK
Install JDK, an IDE such as Eclipse/NetBeans or a programming text editor. You need a working Java programming environment to use LWJGL.
Step 2: Download & Install
Download the latest release of LWJGL binary (e.g., lwjgl-2.9.1.zip
) from http://lwjgl.org ⇒ "Download". You may also download the source, javadoc, and applet.
- Unzip the downloaded file "
lwjgl-2.9.1.zip
". The jar-files and native-libraries are kept in the "jar" and "native" sub-directories, respectively.
(Optional) Create a LWJGL binary directory, says "lwjgl-2.9.1
" - I shall denote the binary directory as $LWJGL_HOME
. Create sub-directories "jar
", "lib
", "src
", "javadoc
" under the $LWJGL_HOME
. Copy the necessary jar-file, native libraries of your operating platform, and source-files into the appropriate sub-directories. For example, for Win32, copy all the jar-file into "jar
"; the 32-bit libraries at "native\windows" into "lib
"; and "lwjgl-source-2.9.1.zip
" into "src
" (no need to unzip). Unzip the javadocs
downloaded into "javadoc
".
Step 3: Customize for Eclipse
- Create a User Library: We shall first create a Eclipse's User Library called "lwjgl-2.9.1", which specifies the jar-files, native libraries (
dll
), javadoc, and source files for the JOGL API. All the JOGL projects can then include this user library in its build path.- From "Window" menu ⇒ Preferences ⇒ Java ⇒ Build Path ⇒ User Libraries ⇒ New ⇒ In "User library name", enter "
lwjgl-2.9.1
". - In "User Library" dialog ⇒ Select "
lwjgl-2.9.1
" ⇒ Add JAR... ⇒ Navigate to "$LWJGL_HOME\jar
", and select "lwjgl.jar
". - Expand the "
lwjgl.jar
" node, select "Native library location: (none)" ⇒ "Edit..." ⇒ External Folder... ⇒ select "$LWJGL_HOME\lib
" (to provide the path for the native codedll
's, such as "lwjgl.dll
", and etc.). You might need to repeat the above step for the other jar-files if they are used in your programs. - (Optional But Recommended) Expand the "
lwjgl.jar
" node again ⇒ Select "Javadoc location"
⇒ "Edit..."- Specify the javadoc's path (either file: or http:) in "Javadoc URL" if you use an unzip version of the javadoc.
- Specify the javadoc's archive file (either zip or jar) in "Javadoc in archive" if you use a zip file.
Choose "Validate", which search for an "
index.html
" file. This is needed for Eclipse to display javadoc information about classes and methods. - (Optional But Recommended) You may provide the source files by editing "Source attachment" ⇒ "Edit..." ⇒ "External File..." ⇒ Select the source file in zip form. Source is needed only if you are interested to debug into the JOGL source codes.
- From "Window" menu ⇒ Preferences ⇒ Java ⇒ Build Path ⇒ User Libraries ⇒ New ⇒ In "User library name", enter "
- Include the User Library: For EACH JAVA PROJECT created that uses LWJGL, right-click on the project ⇒ Build Path ⇒ Add Libraries ⇒ Select "User Library" ⇒ Check "
lwjgl-2.9.1
".
Step 4: Customize for JDK/Editor
You need to modify two environment variables - CLASSPATH
and PATH
. Read "Environment Variables For Java Applications" on how to set these environment variables.
Modify the CLASSPATH
environment variable to include the full-path filenames of "lwjgl.jar
", for example,
prompt> set classpath=.;$LWJGL_HOME\lib\lwjgl.all.jar
where $LWJGL_HOME
denotes the LWJGL installed directory. Take note that you should include the current working directory '.'
.
Modified the PATH
environment variable to include the full path to the LWJGL's "lib
" directory for accessing the native libraries (e.g., "lwjgl.dll
"), for example,
prompt> set path=$LWJGL_HOME\lib;......